package com.geek.demo01.annotation;

import com.geek.demo01.model.UserBO;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Classname: PasswordValidator
 * @Author: Ming
 * @Date: 2020/2/16 3:11 下午
 * @Version: 1.0
 * @Description: 密码确认检验   ConstraintValidator<自定义注解, 自定义注解修饰的目标的类型>
 **/
public class PasswordValidator implements ConstraintValidator<PasswordEqual, UserBO> {

    @Override
    public boolean isValid(UserBO personDTO, ConstraintValidatorContext constraintValidatorContext) {
        String password1 = personDTO.getPassword();
        String password2 = personDTO.getConfirmPassword();
        return password1.equals(password2);
    }
}
